2
2
.
.
3
3
.
.
5
5
E
E
n
n
u
u
m
m
e
e
r
r
a
a
t
t
o
o
r
r
s
s
-
-
T
T
e
e
m
m
p
p
l
l
a
a
t
t
e
e
I
I
n
n
f
f
o
o
While Value Enumerators allow you to select specific Value, Template Enumerators don't have any values.
Instead, Template Enumerators allow you to select a Template which is a combination of Data Types: String, Int, Float.
After selecting a Template you then give any Value to each Data Type in predefined order (even with named Parameters).
Initializer is used to define default Alias when none is specified during assignment to Variable Errors().
T
T
e
e
m
m
p
p
l
l
a
a
t
t
e
e
E
E
n
n
u
u
m
m
e
e
r
r
a
a
t
t
o
o
r
r
S
S
y
y
n
n
t
t
a
a
x
x
Template Enumerator is declared by
using Keyword enum
followed by Name Errors
followed by Templates & their Aliases case Error (Int, String)
Template Enumerator Syntax
//DECLARE TEMPLATE ENUMERATOR.
enum Errors {
//DECLARE TEMPLATE ALIASES.
case Error (Int, String) //Error(1,"RED"), Error(2,"BLUE")
case State (Int) //Aliases must have unique names.
case Warning (code:Int, message:String) //Named Parameters.
case Exception //Specific alias.
//DECLARE INITIALIZER.
init() { self = Error(1,"RED") } //Specifies default Template.
}
//DECLARE TEMPLATE ENUMERATOR VARIABLES.
var connectionError1 : Errors = Errors.Error (1,"RED") //Error(1, "RED")
var connectionError2 : Errors = Errors.State (1) //State(1)
var connectionError3 : Errors = Errors.Warning(code:1, message:"Ups") //Can't change order of arguments.
var connectionError : Errors = Errors() //Default: Errors.Error(1, "RED")
//DISPLAY TEMPLATE ENUMERATOR VARIABLES.
print(connectionError1) //Error(1, "RED")
print(connectionError2) //State(1)
print(connectionError3) //Warning(1, "Ups")